package cn.bonoon.core.plugins;

import cn.bonoon.entities.AccountEntity;
import cn.bonoon.kernel.exceptions.PasswordVerifierException;
import cn.bonoon.kernel.support.IOperator;
import cn.bonoon.kernel.support.services.GenericService;
import cn.bonoon.kernel.support.services.UserService;

/**
 * 登录账户的服务对象
 * 
 * @author jackson
 * 
 */
public interface AccountService extends GenericService<AccountEntity>, UserService {

	/**
	 * 未审核
	 */
	String DRAFT_NAME = "未审核";

	/**
	 * 正常状态
	 */
	String NORMAL_NAME = "正常";

	/**
	 * 不可用状态
	 */
	String FORBID_NAME = "禁用";
	
//	void update(AccountEntity entity,Long[] rids, Long[] gids);

//	void save(AccountEntity entity, String pwd, String repwd, Long[] rids, Long[] gids)throws PasswordVerifierException;
//
//	List<String> ownedModules(Long userId);

//	String defaultModule(String loginName);

//	List<Long> getRoleIdByUser(Long uid);

//	List<Long> getGroupIdByUser(Long uid);

//	List<GroupMemberEntity> getGroupMembers(Long accountId);

//	List<PrivilegeEntity> getPrivileges(Long uid);

//	List<GroupEntity> getGroups(Long uid);

//	List<RoleEntity> getRoles(Long uid);

//	Page_delete<RoleEntity> accountRoles(Long id, PageCondition pc);

//	Page<GroupMemberEntity> accountGroup(Long id, PageCondition pc);
	
	//AccountEntity get(Long id);
	
	/**
	 * 用户自己修改的密码，修改密码的时候在这里的密码是经过了MD5加密的密码
	 * @param uid
	 * @param oldPwd MD5加密的密码
	 * @param newPwd MD5加密的密码
	 * @param repwd MD5加密的密码
	 * @throws PasswordVerifierException
	 */
	void modify(Long uid, String oldPwd, String newPwd, String repwd)throws PasswordVerifierException;
	
	/**
	 * 这里是系统管理员对账号进行密码的修改，这里值进来的密码为明文
	 * @param id
	 * @param pwd 明文密码
	 * @param repwd 明文密码
	 * @param enforce
	 * @return 明文返回保存成功的密码
	 * @throws PasswordVerifierException
	 */
	String resetPassword(IOperator opt, Long id, String pwd, String repwd, boolean enforce)throws PasswordVerifierException;

	/**
	 * 生成一个随机的密码,随机密码需要以明文的方式返回
	 * @param id
	 * @param enforce
	 * @return 明文返回保存成功的密码
	 * @throws PasswordVerifierException
	 */
	String randomPassword(IOperator opt, Long id, boolean enforce)throws PasswordVerifierException;

	/**
	 * 保存用户信息
	 * @param entity
	 */
	void saveAccount(AccountEntity entity);

}
